//
//  NRWCarListRejectCell.m
//  New_Runway
//
//  Created by 张记 on 2018/5/3.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "NRWCarListRejectCell.h"
@interface NRWCarListRejectCell ()
@property (weak, nonatomic) IBOutlet UIImageView *leftImage;
@property (weak, nonatomic) IBOutlet UIImageView *rightImage;
@property (weak, nonatomic) IBOutlet UIImageView *mainImage;
@property (weak, nonatomic) IBOutlet UILabel *mainTitle;
@property (weak, nonatomic) IBOutlet UILabel *contentL;
@property (weak, nonatomic) IBOutlet UILabel *typeL;
@property (weak, nonatomic) IBOutlet UILabel *priceL;
@property (weak, nonatomic) IBOutlet UIButton *checkBtn;

@end
@implementation NRWCarListRejectCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.checkBtn.layer.masksToBounds = YES;
    self.checkBtn.layer.cornerRadius = 5;
    
}
-(void)setIndex:(NSIndexPath *)index{
    _index = index;
}
-(void)setCarModel:(Result *)carModel{
    _carModel = carModel;
    
    [self.mainImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@.r_240xh_170",ImageApi,carModel.carImageUrl]] placeholderImage:[UIImage imageNamed:@"tu"]];
    self.mainTitle.text =carModel.carTitle;
    
    self.rightImage.image = [UIImage imageNamed:@""];;
    
    if (carModel.carOrderState == 1 ) {
        self.rightImage.image = [UIImage imageNamed:@"mark-b"];;
    }
    if (carModel.carBargainPriceState == 1 ) {
        self.rightImage.image = [UIImage imageNamed:@"mark-c"];;
    }
    
    if (carModel.carRetailPrice <= 0) {
        self.priceL.text = @"价格面议";
     
    }else{
        self.priceL.text =  [NSString stringWithFormat:@"%.2f万",(CGFloat)carModel.carRetailPrice];
    }
    
    NSString *carSctockStr;
    if (carModel.carStockState == 0) {
        carSctockStr = @"未完成入库";
    }else if (carModel.carStockState == 1){
         carSctockStr = @"审核驳回";
    }else if (carModel.carStockState == 2){
         carSctockStr = @"撤销入库";
    }else if (carModel.carStockState == 10){
        carSctockStr = @"入库审核";
    }else if (carModel.carStockState == 20){
        carSctockStr = @"已入库";
        if (carModel.carSaleState == 0) {
            carSctockStr = @"未上架";
        }else if (carModel.carSaleState == 10){
            carSctockStr = @"上架中";
        }else if (carModel.carSaleState == 20){
            carSctockStr = @"已上架";
            
        }else if (carModel.carSaleState == 30){
            carSctockStr = @"已下架";
        }
        
    }else if (carModel.carStockState == 30){
        carSctockStr = @"出库审核";
    }else if (carModel.carStockState == 40){
        carSctockStr = @"已出库";
    }else{
        carSctockStr = @"--";
    }
    NSString *carAuthStr;
    if (carModel.carAuthState == 0) {
        if (carModel.carDetectState == 500) {
            carAuthStr = @"未初检";
        }else if (carModel.carDetectState == 510){
            carAuthStr = @"初检不通过";
        }else if (carModel.carDetectState == 520){
            carAuthStr = @"初检通过";
        }else if (carModel.carDetectState == 530){
            carAuthStr = @"申请复检中";
        }else if (carModel.carDetectState == 540){
            carAuthStr = @"复检完成";
        }
        self.leftImage.hidden = YES;
        
    }else{
        carAuthStr = @"已认证";
        self.leftImage.hidden = NO;
    }
  
    self.typeL.text = [NSString stringWithFormat:@"%@ / %@",carSctockStr,carAuthStr];
    self.typeL.textColor = MAIN_NAV_COLOR();
    NSString *mileageStr;
    if ([carModel.carMileage doubleValue] <= 0) {
        mileageStr = @"未输入里程";
    }else{
        
        if ([carModel.carMileage doubleValue] < 0.1) {
            mileageStr = [NSString stringWithFormat:@"%.f公里", [carModel.carMileage doubleValue] *10000];
            
        }else{
            mileageStr = [NSString stringWithFormat:@"%.2f万公里", [carModel.carMileage doubleValue]];
            
        }
        
    }
    if (carModel.carLicenceState == 1 ) {
        
        self.contentL.text = [NSString stringWithFormat:@"%@ | %@年",mileageStr, [NRWCarTurnTime timestampSwitchTime:carModel.carLicenceDate andFormatter:@"YYYY"]];
    }else if (carModel.carLicenceState == 2){
        self.contentL.text = [NSString stringWithFormat:@"%@ | 未上牌",mileageStr];
    }else if (carModel.carLicenceState == 3 ){
        self.contentL.text = [NSString stringWithFormat:@"%@ | 新车",mileageStr];
    }
    
}
- (IBAction)refuseBtn:(id)sender {
    [self routerEventWithName:@"refuse" userInfo:@{@"index" : self.index}];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
